﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Repository;
using Domain;
using Controller;

namespace Ecommerce
{
    public partial class Login : Form
    {

        private FormularioPrincipal frmPrincipal;
        public Login(FormularioPrincipal frmPrincipal)
        {
            InitializeComponent();
            this.frmPrincipal = frmPrincipal;
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            ClienteController cc = new ClienteController();
            Cliente c = new Cliente();
            c = cc.login(textBox1.Text, maskedTextBox1.Text);
            EnderecoController ec = new EnderecoController();

            c.Endereco = ec.listarEndereco(c.Id_cliente);
            if (c != null)
            {
                this.frmPrincipal.PreparaFormulario(c);
                this.Dispose();
            }
            else
            {
                MessageBox.Show("Usuario ou senha estão incorretos!");
            }   
        }

        private void Login_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {

        }
    }
}
